class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        if (strs.size() == 0) {
            return "";
        }
        int len = 0;
        string res{};
        while(true) {
            char base = strs[0][len];
            for (auto s: strs) {
                if (len == s.size()) {
                    goto ret;
                }
                if (s[len] != base) {
                    goto ret;
                }
            }
            len ++;
        }
        ret:
        // get strs
        res = strs[0].substr(0, len);
        return res;
    }
};